package cn.com.git.admin.server.ctrler;

import cn.com.git.admin.server.api.feign.upms.SystemFeignService;
import cn.com.git.admin.service.dto.SysNoteDictDetailDTO;
import cn.com.git.admin.service.dto.SysNoteDictListDTO;
import cn.com.git.admin.service.dto.SysNoteDictSaveDTO;
import cn.com.git.admin.service.query.SysNoteDictListQuery;
import cn.com.git.common.base.BaseController;
import cn.com.git.common.model.ResultMsg;
import cn.com.git.common.model.ResultPage;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.ModelAndView;

/**
 * @author zhangzhenfu
 * @Description
 * @date 2020/3/1 0001 12:26
 */
@Controller
@RequestMapping("/sys_note_dict")
public class SysNoteDictCtrler extends BaseController {

    @Autowired
    private SystemFeignService systemFeignService;

    @RequestMapping(value = "/index",method = RequestMethod.GET)
    public ModelAndView index(){
        ModelAndView mv = new ModelAndView("sys_note_dict/index");
        return mv ;
    }
    @RequestMapping(value = "/list/page", method = RequestMethod.POST)
    @ResponseBody
    public ResultPage<SysNoteDictListDTO> listPage(SysNoteDictListQuery query) {
        return systemFeignService.sysNoteDictListPage(query);
    }
    @RequestMapping(value = "/add", method = RequestMethod.GET)
    public ModelAndView add() {
        ModelAndView mv = new ModelAndView("sys_note_dict/add");
        return mv ;
    }
    @RequestMapping(value = "/add", method = RequestMethod.POST)
    @ResponseBody
    public ResultMsg<SysNoteDictSaveDTO> add(@RequestBody SysNoteDictSaveDTO form) {
        ResultMsg<SysNoteDictSaveDTO> resultMsg = systemFeignService.sysNoteDictAdd(form);
        return resultMsg;
    }
    @RequestMapping(value = "/edit", method = RequestMethod.POST)
    @ResponseBody
    public ResultMsg<SysNoteDictSaveDTO> edit(@RequestBody SysNoteDictSaveDTO form) {
        ResultMsg<SysNoteDictSaveDTO> resultMsg = systemFeignService.sysNoteDictEdit(form);
        return resultMsg;
    }
    @RequestMapping(value = "/edit/{id}", method = RequestMethod.GET)
    public ModelAndView edit(@PathVariable("id") Integer id) {
        ModelAndView mv = new ModelAndView("sys_note_dict/edit");
        ResultMsg<SysNoteDictDetailDTO> resultMsg = systemFeignService.sysNoteDictFind(id);
        mv.addObject("dto",resultMsg.getData());
        return mv ;
    }
    @RequestMapping(value = "/delete/{id}", method = RequestMethod.GET)
    @ResponseBody
    public ResultMsg delete(@PathVariable("id") Integer id) {
        ResultMsg resultMsg = systemFeignService.sysNoteDictDelete(id);
        return resultMsg;
    }
}
